package com.poetize.plus.entity.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.poetize.plus.entity.po.TimeLine;
import io.swagger.v3.oas.annotations.media.Schema;

import java.time.LocalDateTime;

/**
 * @author zuosy
 * @created 2024/5/13 14:57
 */
public record TimeLineVO(

        @Schema(description = "ID")
        Long id,

        @Schema(description = "发生时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        LocalDateTime occurrenceTime,

        @Schema(description = "内容")
        String content,

        @Schema(description = "创建时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        LocalDateTime createTime
) {

    /**
     * 实体类转VO
     * @param timeLine
     * @return
     */
    public static TimeLineVO convert(TimeLine timeLine){
        return new TimeLineVO(timeLine.getId(), timeLine.getOccurrenceTime(), timeLine.getContent(), timeLine.getCreateTime());
    }
}
